package cn.lqz.bucttrain.pojo.dto;

import cn.lqz.bucttrain.contants.TrainConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 列车新增或修改
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TrainCreateOrUpdateDTO {
    /**
     * 列车id
     */
    private Long trainId;
    /**
     * 车次
     */
    private String trainNumber;
    /**
     * 列车类型：0普通，1特快
     */
    @NotNull
    private Integer type;
    /**
     * 发车时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime startTime;
    /**
     * 停车时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime stopTime;
    /**
     * 商务座数量
     */
    @Min(0)
    private Integer businessNum;
    /**
     * 普通座数量
     */
    @Min(0)
    private Integer commonNum;
    /**
     * 状态：0禁用，1启用，2维修
     */
    @NotNull
    private Integer status;



/**
 * 前端传的是座位数量，后端存的是座位行数
 */
    /**
     * 商务座行数
     */
    private Integer businessRow;
    /**
     * 普通座行数
     */
    private Integer commonRow;

    public Integer getBusinessRow(){
        return businessNum==null?null:businessNum/TrainConstants.BUSINESS_ROW_SEAT;
    }
    public Integer getCommonRow(){
        return commonNum==null?null:commonNum/TrainConstants.COMMON_ROW_SEAT;
    }

}
